# coding=utf-8
"""
    @project: 15python_spider
    @Author：frank
    @file： 02_renrenlogin_session.py
    @date：2024/3/4 20:32
"""
import requests
from fake_useragent import UserAgent

post_url = 'http://www.renren.com/PLogin.do'
get_url = 'http://www.renren.com/970294164/profile'
post_data = {
    'email': '15110225726',
    'password': 'zhanshen001'
}
headers = {
    'User-Agent': UserAgent().random,
    'Referer': 'http://www.renren.com'
}

# 实例化session对象
session = requests.session()
# 先登录
session.post(url=post_url, data=post_data, headers=headers)
# 再GET -> 个人主页（需要登录才能访问的页面）
html = session.get(url=get_url, headers=headers).text

print(html)
